<template>
  <div>
    <div class="top">
      <div class="header">
        <van-nav-bar left-arrow @click-left="$router.push('/index')" />
        <img
          class="bgimg"
          :src="'https://elm.cangdu.org/img/' + obj.image_path"
          alt=""
        />
        <div class="left">
          <img :src="'https://elm.cangdu.org/img/' + obj.image_path" alt="" />
        </div>
        <div class="right">
          <van-icon name="arrow" />
          <h2>{{ obj.name }}</h2>
          <p>
            {{
              obj.delivery_mode &&
              obj.delivery_mode.text +
                "/" +
                obj.float_minimum_order_amount +
                "分钟送达/" +
                obj.piecewise_agent_fee.tips
            }}
          </p>
          <p>{{ obj.promotion_info }}</p>
        </div>
        <p
          @click="btn"
          class="huodong"
          v-if="obj.activities && obj.activities.length"
        >
          <span
            :style="{
              backgroundColor: '#' + obj.activities[0].icon_color,
            }"
            class="icon"
            >{{ obj.activities[0].icon_name }}</span
          >
          <span>{{ obj.activities[0].description }}</span>
          <span class="all"
            >{{ obj.activities.length }}个活动 <van-icon name="arrow"
          /></span>
        </p>
      </div>
      <van-overlay :show="show" @click="show = false" z-index="9999999999">
        <div class="wrapper">
          <h2>{{ obj.name }}</h2>
          <p class="title"><span>优惠信息</span></p>
          <p v-for="item in obj.activities" :key="item.id" class="content">
            <span
              :style="{
                backgroundColor: '#' + item.icon_color,
              }"
              class="icon"
              >{{ item.icon_name }}</span
            ><span>{{ item.description }}</span>
          </p>
          <p class="title"><span>商家公告</span></p>
          <p class="content">{{ obj.promotion_info }}</p>
        </div>
      </van-overlay>
      <div class="buttom">
        <van-tabs sticky offset-top="0" v-model="tabName" @click="curTabFn">
          <van-tab title="商品"> </van-tab>
          <van-tab title="评价"> </van-tab>
        </van-tabs>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false,
      tabName: Number(this.$route.query.tabName)
        ? Number(this.$route.query.tabName)
        : 0,
    };
  },
  props: {
    obj: {
      type: Object,
    },
  },
  methods: {
    btn() {
      this.show = true;
    },
    curTabFn(name, title) {
      if (name == 1) {
        this.$router.push({
          path: "/evaluate",
          query: {
            id: this.$route.query.id,
            tabName: name,
          },
        });
      } else {
        this.$router.push({
          path: "/shopDetail",
          query: {
            id: this.$route.query.id,
            tabName: name,
          },
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.van-nav-bar .van-icon {
  color: #fff;
}
.buttom {
  margin-top: -45px;
}
.top {
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9;
  .header {
    height: 150px;
    width: 100vw;
    display: flex;
    overflow: hidden;
  }
  .bgimg {
    width: 100vw;
    height: 650px;
    filter: blur(10px);
  }
  .left {
    position: absolute;
    flex: 1;
    float: left;
    img {
      width: 90px;
      height: 90px;
      margin: 20px;
    }
  }
  .right {
    margin-top: -15px;
    position: absolute;
    left: 30%;
    flex: 1;
    float: right;
    font-size: 14px;
    margin-top: 10px;
    p {
      margin: 15px 0;
    }
    h2 {
      font-size: 25px;
      font-weight: 700;
      margin-top: 15px;
    }
  }
}
.van-icon-arrow:before {
  position: relative;
  top: 50px;
  right: -2800%;
  color: #000;
  font-size: 16px;
}
/deep/.van-sticky {
  margin-top: 45px;
  background-color: #fff;
  z-index: 999999;
}
.van-icon-arrow-left {
  position: absolute;
  top: 10px;
  left: 15px;
  z-index: 999;
  color: #000;
}
.huodong {
  width: 89%;
  position: absolute;
  bottom: 54px;
  left: 35px;
  font-size: 14px;
  .icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 12px;
    margin-right: 5px;
    text-align: center;
    border-radius: 2px;
  }
  .all {
    float: right;
    .van-icon-arrow[data-v-901cd538]:before {
      z-index: 999;
      color: #fff;
      position: relative;
      top: 0;
      left: 0;
    }
  }
}
.wrapper {
  height: 100%;
  h2 {
    color: #fff;
    text-align: center;
    margin-top: 100px;
    font-size: 25px;
  }
  p {
    margin-top: 30px;
    color: #fff;
  }
  .title {
    text-align: center;
    span {
      display: inline-block;
      width: 80px;
      height: 30px;
      line-height: 30px;
      border-radius: 15px;
      border: 1px solid #ccc;
    }
  }
  .content {
    margin-left: 50px;
  }
  .icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 12px;
    border-radius: 3px;
  }
}
/deep/.van-overlay {
  background-color: rgba(0, 0, 0, 0.99);
}
</style>